package com.tomehay.termprojectmanage_server.mapper;
import org.apache.ibatis.annotations.Param;

import com.tomehay.termprojectmanage_server.pojo.Model.GroupTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tomehay.termprojectmanage_server.pojo.VO.GroupTaskVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */

@Mapper
public interface GroupTaskMapper extends BaseMapper<GroupTask> {

    @Select("select * from group_task  ")
    List<GroupTask> selectInfoById(Integer groupID,Integer termProjectId);
//    @Select("select * from group_task  where group_id = #{groupID} and termProjectId =#{termProjectId}")

    List<GroupTask> selectAllByGroupId(@Param("groupId") Integer groupId);

    @Select("SELECT group_task.* FROM group_task,termproject,allocation WHERE termproject.course_id = #{course_id} " +
            "AND allocation.id = group_task.allocation_id AND allocation.term_project_id = termproject.id AND group_task.isEnd = #{isEnd}")
    List<GroupTask> selectUnEndGroupTask(int course_id,int isEnd);

    @Select("SELECT group_task.id,group_task.teacher_id,group_task.group_task_no,group_task.`name`,group_task.`status`,termproject.title,allocation.group_id FROM group_task,termproject,allocation WHERE termproject.course_id = #{course_id} " +
            "AND allocation.id = group_task.allocation_id AND allocation.term_project_id = termproject.id AND group_task.isEnd = #{isEnd}")
    List<GroupTaskVO> selectGroupTaskVO(int course_id,int isEnd);

    @Select("SELECT group_task.id,group_task.teacher_id,group_task.group_task_no,group_task.`name`,group_task.`status`,termproject.title,allocation.group_id FROM group_task,termproject,allocation WHERE termproject.id = #{termProjectId} " +
            "AND allocation.id = group_task.allocation_id AND allocation.term_project_id = termproject.id AND group_task.isEnd = #{isEnd}")
    List<GroupTaskVO> selectGroupTaskVOByTermProjectID(int isEnd,int termProjectId);

    List<GroupTask> selectAllByAllocationId(@Param("allocationId") Integer allocationId);
}
